﻿<?php
$connect=mysql_connect("localhost","root","");
mysql_select_db("shenji",$connect);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.6.3.min.js"></script>
</head>

<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">升级包管理</a></li>
	<li><a href="#">上传升级包</a></li>
    </ul>
    </div>
    
    <div class="formbody">
    <div class="formtitle"><span>基本信息</span></div>
    <form method="post" action="insert_shenji_commit.php" enctype="multipart/form-data">
    <ul class="forminfo">
    <li>
	<label>类型</label>
	<select name="type" id="type" style="width:80px;">
	<?php
	  //从数据库中取出类型type
	  $sql2="select * from type";
	  $result2=mysql_query($sql2);
	  while($row2=mysql_fetch_array($result2)){  
	?>
	 <option value="<?php echo $row2['name'];?>"><?php echo $row2['name'];?></option>
	<?php
	 }
	?>
    </select>
	</li>
    <li><label>升级包</label><input name="file" id="file" type="file" style="width:122px;"/></li>
    <li><label>测试的机器码</label>
    <select name="publish_jiqi" id="publish_jiqi">
    <?php
	    $jiekou_sql="select * from jiekou";
		$jiekou_result=mysql_query($jiekou_sql);	 
		while($jk_row=mysql_fetch_array($jiekou_result)){	   		   
	?>
	    <option value="<?php echo $jk_row['id'];?>"><?php echo $jk_row['beizhu'];?></option>	 
	<?php
		}
	?>
	</select>
	</li>
    <li><label>&nbsp;</label><input name="" type="submit" class="btn" value="确认保存" onclick="return tijiao();"/></li>
    </ul>
	</form>
    </div>
</body>
</html>
<script>
function tijiao(){
	var name=$("#file").val();  
	var re =/update+\w*.tar.gz/;
	var result=re.test(name);
	var fileInput = $("#file")[0];
	var byteSize  = fileInput.files[0].size;
	var size1=Math.ceil(byteSize/1024000);
    if(result&&size1<=200){
		return true;			
	}else{
		 alert("请输入正确的升级文件update*.tar.gz并且文件大小不超过200M"); 
		 return false;
	} 
}
</script>

